package com.hspedu.exception_.homework;

/**
 * @Author Stringzhua
 * @Date 2024/3/8 13:19
 * description:
 * 出现了什么异常?
 * Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
 * at com.hspedu.exception_.homework.homework02.main(homework02.java:13)
 */
public class homework02 {
    public static void main(String[] args) {
        //args.length=0
        //这里发生的是 ArrayIndexOutOfBoundsException
//        args[4] = null;
        if (args[4].equals("john")) {//可能发生空指针异常
            System.out.println("AA");
        } else {
            System.out.println("BB");
        }
        Object o = args[2];//String-<Object  向上转型
        Integer i = (Integer) o;//错误,这里一定会发生ClassCaseException  java.lang.String cannot be cast to java.lang.Integer
    }
}
